package com.sendtion.xrichtextdemo.comm;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.zhihu.matisse.engine.ImageEngine;

import ohos.agp.components.Image;
import ohos.agp.components.element.Element;
import ohos.app.Context;
import ohos.utils.net.Uri;

/**
 * MyGlideEngine
 *
 * @since 2021-06-22
 */
public class MyGlideEngine implements ImageEngine {
    @Override
    public void loadThumbnail(Context context, int resize, Element placeholder, Image imageView, Uri uri) {
        Glide.with(context)
                .asBitmap()
                .load(uri)
                .placeholder(placeholder)
                .override(resize, resize)
                .centerCrop()
                .into(imageView);
    }

    @Override
    public void loadGifThumbnail(Context context, int resize, Element placeholder, Image imageView, Uri uri) {
        Glide.with(context)
                .asBitmap()
                .load(uri)
                .placeholder(placeholder)
                .override(resize, resize)
                .centerCrop()
                .into(imageView);
    }

    @Override
    public void loadImage(Context context, int i, int i1, Image image, Uri uri) {
        Glide.with(context)
                .load(uri)
                .override(i, i1)
                .priority(Priority.HIGH)
                .into(image);
    }

    @Override
    public void loadGifImage(Context context, int i, int i1, Image image, Uri uri) {
        Glide.with(context)
                .load(uri)
                .override(i, i1)
                .priority(Priority.HIGH)
                .into(image);
    }

    @Override
    public boolean supportAnimatedGif() {
        return false;
    }
}
